<!-- 搜索列表2 -->
<template>
	<lilo-form-table ref="formTable" showFieldChecked :query-info="queryInfo" :form-data="formData" :table-data="tableData" label-width="30px"></lilo-form-table>
</template>

<script>
import { Query60RkPageList } from '@/api/data-management/laoren/index';
import { HYZK, XB, MZ, RYLB, ZZMM } from '@/utils/dictionary.js';
import { mapGetters } from 'vuex';
import { getTreeNew1 } from '@/api/data-management/one-surface/index';
export default {
	data() {
		let validate = (rule, value, callback) => {
			if (Number(value) > Number(this.formdata.Start_NL) || Number(value) == 0) {
				callback();
			} else {
				callback(new Error('请输入正确年龄'));
			}
		};
		return {
			allFieldChecked: true,
			MZ: MZ,
			DRYLB: RYLB,
			XB: XB,
			HYZK: HYZK,
			queryInfo: {
				entity: Query60RkPageList,
				param: {
					pageNo: 1,
					pageSize: 15
				}
			},
			formData: {
				dataProvider: {
					XINGMING: '',
					ZHENGJIANHAOMA: '',
					XINGBIE: '',
					HUNYINZHUANGKUANG: '',
					JIGUAN: '',
					Start_NL: '60',
					End_NL: '',
					JUZHUDIZHI: '',
					WANGGE: ''
				},
				rules: {
					XINGMING: [
						{
							min: 1,
							max: 5,
							message: '长度在 1 到 5 个字符'
						},
						{
							pattern: /^[\u4E00-\u9FA5]+$/,
							message: '用户名只能为中文'
						}
					],
					ZHENGJIANHAOMA: [
						{
							pattern: /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
							message: '证件号码格式有误！'
						}
					],
					Start_NL: [{ required: false, trigger: 'blur' }, { pattern: /^\+?[1-9]\d*$/, message: '请输入正确年龄', trigger: 'blur' }],
					End_NL: [{ validator: validate, trigger: 'change' }]
				},
				templates: [
					{
						layout: { xs: 24, sm: 24, md: 24, lg: 24, xl: 24 },
						component: {
							name: 'Divider',
							label: '条件搜索'
						}
					},
					{
						layout: { xs: 24, sm: 24, md: 4, lg: 4, xl: 4 },
						field: 'XINGMING',
						fieldChecked: true,
						component: {
							name: 'Input',
							placeholder: '请输入姓名',
							clearable: true
						}
					},
					{
						layout: { xs: 24, sm: 24, md: 4, lg: 4, xl: 4 },
						field: 'ZHENGJIANHAOMA',
						fieldChecked: true,
						component: {
							name: 'Input',
							placeholder: '请输入身份证号',
							clearable: true
						}
					},
					{
						layout: { xs: 24, sm: 24, md: 4, lg: 4, xl: 4 },
						field: 'XINGBIE',
						fieldChecked: true,
						component: {
							name: 'Select',
							placeholder: '请选择性别',
							clearable: true,
							options: XB
						}
					},
					{
						layout: { xs: 24, sm: 24, md: 4, lg: 4, xl: 4 },
						field: 'HUNYINZHUANGKUANG',
						fieldChecked: true,
						component: {
							name: 'Select',
							placeholder: '请选择婚姻状况',
							clearable: true,
							options: HYZK
						}
					},
					{
						layout: { xs: 24, sm: 24, md: 4, lg: 4, xl: 4 },
						field: 'JIGUAN',
						fieldChecked: true,
						component: {
							name: 'Input',
							placeholder: '请输入籍贯',
							clearable: true
						}
					},
					{
						layout: { xs: 24, sm: 24, md: 2, lg: 2, xl: 2 },
						field: 'Start_NL',
						fieldChecked: true,
						component: {
							name: 'Input',
							disabled: true
						}
					},
					{
						layout: { xs: 24, sm: 24, md: 2, lg: 2, xl: 2 },
						field: 'End_NL',
						fieldChecked: true,
						component: {
							name: 'Input',
							placeholder: '结束年龄'
						}
					},
					{
						layout: { xs: 24, sm: 24, md: 4, lg: 4, xl: 4 },
						field: 'JUZHUDIZHI',
						fieldChecked: true,
						component: {
							name: 'Input',
							placeholder: '现居住地',
							clearable: true
						}
					},
					{
						layout: { xs: 24, sm: 24, md: 4, lg: 4, xl: 4 },
						field: 'WANGGE',
						fieldChecked: true,
						component: {
							name: 'Select',
							placeholder: '请选择网格',
							clearable: true,
							optionKey: 'value',
							optionLabel: 'title',
							options: []
						}
					},
					{
						layout: { xs: 24, sm: 24, md: 8, lg: 8, xl: 8 },
						component: {
							name: 'Template',
							templates: [
								{
									name: 'Button',
									label: '查询',
									type: 'primary',
									icon: 'el-icon-search',
									click: this.query
								},
								{
									name: 'Button',
									label: '全选',
									type: 'danger',
									icon: 'el-icon-check',
									click: this.select
								},
								{
									name: 'Button',
									label: '重置',
									icon: 'el-icon-refresh-right',
									click: this.reset
								}
							]
						}
					}
				]
			},
			tableData: {
				autoHeight: true, //是否自动计算table高度，默认为true
				deltaHeight: 145, //table的高度微调，配合自动计算高度使用，默认值为145
				dataProvider: {
					tablelist: []
				},
				templates: [
					{
						layout: { xs: 24, sm: 24, md: 24, lg: 24, xl: 24 },
						component: {
							name: 'Divider',
							label: '人员列表'
						}
					},
					{
						layout: { xs: 24, sm: 24, md: 24, lg: 24, xl: 24 },
						field: 'tablelist',
						// label: '核酸检测机构名称',
						labelWidth: '0px',
						component: {
							name: 'Table',
							columns: [
								{
									field: 'xm',
									label: '姓名',
									width: 80
								},
								{
									field: 'xingbie',
									label: '性别',
									width: 50,
									formatter: (dp, row, col) => {
										let text = '';
										if (row.xingbie == '1') {
											text = '男';
										} else if (row.xingbie == '2') {
											text = '女';
										}
										return text;
									}
								},
								{
									field: 'mingzu',
									label: '民族',
									width: 100,
									formatter: (dp, row, col) => {
										for (let i = 0; i < this.MZ.length; i++) {
											let mz = this.MZ[i];
											if (row.mingzu == mz.value) {
												return mz.label;
											}
										}
									}
								},
								{
									field: 'age',
									label: '年龄',
									width: 80
								},
								{
									field: 'ymjzcs',
									label: '疫苗接种次数',
									width: 100,
									formatter: (dp, row, col) => {
										return row.ymjzcs + '次';
									}
								},
								{
									field: 'renyuanleibie',
									label: '人员类别',
									width: 120,
									formatter: (dp, row, col) => {
										for (let i = 0; i < this.DRYLB.length; i++) {
											let type = this.DRYLB[i];
											if (row.renyuanleibie == type.value) {
												return type.label;
											}
										}
									}
								},
								{
									field: 'shequ',
									label: '所属网格',
									width: 150
								},
								{
									field: 'addressstring',
									label: '地址'
								},
								{
									field: 'lianxidianhua',
									label: '联系电话',
									width: 150
								},
								{
									field: 'count',
									label: '数量',
									templates: [
										{
											name: 'Button',
											type: 'text',
											// click: this.openLayer
										}
									],
									formatter: (dp, row, col) => {
										return row.count;
									}
								},
								{
									field: 'readtime',
									label: '维护时间',
									width: 150
								},
								{
									label: '操作',
									width: 100,
									fixed: 'right',
									templates: [
										{
											name: 'Button',
											label: '编辑',
											type: 'primary',
											// icon: 'el-icon-search',
											click: this.qianshouHandler
										}
									]
								}
							]
						}
					}
				]
			}
		};
	},
	created() {
		this.getWangGe();
		this.formData.dataProvider.WANGGE = this.linkOrgcode;
	},
	computed: {
		...mapGetters({
			userinfo: 'userInfo',
			orgcode: 'orgcode',
			linkOrgcode: 'linkOrgcode'
		})
	},
	methods: {
		getWangGe() {
			getTreeNew1({ Pid: this.orgcode }).then(
				res => {
					this.$refs.formTable.getForm().setSelectOptions('WANGGE', res.data);
				},
				err => {}
			);
		},
		query() {
			this.$refs.formTable.query();
		},
		reset() {
			this.$refs.formTable.reset();
		},
		select() {
			this.allFieldChecked = !this.allFieldChecked;
			this.$refs.formTable.getForm().setCheckedData('*', this.allFieldChecked);
		},
		qianshouHandler(row) {
			console.log(row);
		}
	}
};
</script>

<style></style>
